package com.tangyuan.video.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.tangyuan.model.Video;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface VideoMapper extends BaseMapper<Video> {

    Video getVideoById(Long videoId, Long userId);
    List<Video> getVideoByIds(@Param("ids") List<Long> ids, Long userId);

    List<Video> getPublishVideoByIds(@Param("ids") List<Long> ids, Long userId);

    @Update("update video set collection_num = collection_num + #{value} where id = #{videoId}")
    void saveCollectionNum(Long videoId, @Param("value") Integer value);

    @Update("update video set thump_up_num = thump_up_num + #{value} where id = #{videoId}")
    void saveThumpUpNum(Long videoId, @Param("value") Integer value);

    long countTopVideosByUserId(Long userId);

    Long getVideoThumpNum(Long userId);
}
